//
//  ActorThreadSafeArray.swift
//  APSwift
//
//  Created by jianbo.pei on 2023/7/25.
//

import Foundation

// 创建对象
actor MyActor {
    private var sharedArr = [1,2,3,4,5]
 
    // 读取数据
    func readData() async -> [Int] {
        return sharedArr
    }
 
    // 添加数据
    func writeData(value: Int) async {
        sharedArr.append(value)
    }
    
    // 删除数据
    func removeData() async {
        sharedArr.removeLast()
    }
}
